package board.dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import board.vo.ReplyVO;
import board.vo.SportsBoardVO;
import board.vo.SportsPagingVO;
import board.vo.TeamVO;
import board.vo.TempVO;



public class BoardDAO {
	
	private SqlMapClientTemplate client ;
	
	public BoardDAO(SqlMapClientTemplate client){
		this.client = client;	
	}
	
	
	public void insertContent(SportsBoardVO sbv) throws SQLException{
		client.insert("insertContent", sbv);		
	}
	
	
	public List allSearchBoard() throws SQLException{
		return client.queryForList("allSearchBoard");		
	}

	public ArrayList selectContentList(SportsPagingVO spv) {
		ArrayList list = (ArrayList)client.queryForList("selectContentList", spv);
		return list;
	}

	
	public SportsBoardVO searchBoardByNo(int no) {
		SportsBoardVO sbv = (SportsBoardVO)client.queryForObject("searchBoardByNo", no);
		return sbv;		
	}
	

	public int deleteWrite(String boardNo) {
		return client.delete("deleteWrite",boardNo);
	}
	

	public void writeModify(SportsBoardVO sbv) {
		client.update("writeModify", sbv);		
	}


	public void insertReply(ReplyVO rvo) {
		client.insert("insertReply", rvo);		
	}


	public ArrayList findReplyByNo(int no) {
		return (ArrayList)client.queryForList("findReplyByNo",no);
	}


	public String searchJoinNickNameById(String id) {	
		return (String)client.queryForObject("searchJoinNickNameById",id);
	}


	public void deleteReply(int replyNo) {
		client.delete("deleteReply",replyNo);
	}


	public ArrayList searchTeamInfoByType(int teamType) throws Exception{		
		return (ArrayList)client.queryForList("searchTeamInfoByType", teamType);
	}
	public ArrayList searchAllTeamInfoByType() throws Exception{
		return (ArrayList)client.queryForList("searchAllTeamInfoByType");
	}


	public TeamVO findTeamInfoByNo(int teamNo) throws Exception{
		return (TeamVO)client.queryForObject("findTeamInfoByNo", teamNo);
	}


	public void boardCountByNo(int no) {
		client.update("boardCountByNo", no);		
	}


	public ArrayList searchFindTitle(SportsPagingVO spv) {
		ArrayList list = (ArrayList)client.queryForList("searchFindTitle", spv);
		return (ArrayList)client.queryForList("searchFindTitle", spv);
	}


	public ArrayList searchFindContent(SportsPagingVO spv) {
		return (ArrayList)client.queryForList("searchFindContent", spv);
	}


	public ArrayList searchFindName(SportsPagingVO spv) {
		return (ArrayList)client.queryForList("searchFindName", spv);
	}


	public ArrayList searchFindTC(SportsPagingVO spv) {
		return (ArrayList)client.queryForList("searchFindTC", spv);
	}

	public int selectTotalCount(int typeNo) {
		int totalCount = Integer.parseInt((String)client.queryForObject("selectTotalCount",typeNo));
		return totalCount;
	}
	
	public int selectTotalCountTitle(int typeNo, String searchTxt) {
		TempVO tempVO = new TempVO(typeNo, searchTxt);
		int totalCount = Integer.parseInt((String)client.queryForObject("selectTotalCountTitle",tempVO));
		return totalCount;
	}

	public int selectTotalCountContent(int typeNo, String searchTxt) {
		TempVO tempVO = new TempVO(typeNo, searchTxt);
		int totalCount = Integer.parseInt((String)client.queryForObject("selectTotalCountContent",tempVO));
		return totalCount;
	}

	public int selectTotalCountNickName(int typeNo, String searchTxt) {
		TempVO tempVO = new TempVO(typeNo, searchTxt);
		int totalCount = Integer.parseInt((String)client.queryForObject("selectTotalCountNickName",tempVO));
		return totalCount;
	}

	public int selectTotalCountTC(int typeNo, String searchTxt) {
		TempVO tempVO = new TempVO(typeNo, searchTxt);
		int totalCount = Integer.parseInt((String)client.queryForObject("selectTotalCountTC",tempVO));
		return totalCount;
	}


	public int selectBoardNo() throws Exception{
		return (Integer)client.queryForObject("selectBoardNo");
	}


	public String typeNameByNo(int typeNo) throws Exception{
		return (String)client.queryForObject("typeNameByNo",typeNo);
	}


	
}






